﻿//获取浏览器参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
/*窗体加载*/
$(function () {
    //使焦点在当前页面
    window.focus();

    var t = getQueryString("t");
    if (t == 1) {
        $(".eject_frame").html("<p>是否清除当前销售内容？</p>");
        $(".eject_operation").html("按ESC键返回,按F1确定");
    }
    else if (t == 2) {

    }
    else if (t == 8) {      //结算页
        $(".eject_frame").html("<p>实收金额不能为空！</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 9) {      //结算页
        $(".eject_frame").html("<p>实收金额小于订单金额？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 10) {     //微信支付
        $(".eject_frame").html("<p>动态码不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 11) {      //结算页
        $(".eject_frame").html("<p>实收金额大于退款金额？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 17) {
        $(".eject_frame").html("<p>手机号码不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 18) {
        $(".eject_frame").html("<p>手机号码格式错误？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 19) {
        $(".eject_frame").html("<p>短信验证码不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 31) {
        $(".eject_frame").html("<p>授权码不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 32) {
        $(".eject_frame").html("<p>单号不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 101) {
        $(".eject_frame").html("<p>账户名或密码不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 102)  {
        $(".eject_frame").html("<p>手机号码不正确？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 201) {
        $(".eject_frame").html("<p>会员卡号或充值金额为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 202) {
        $(".eject_frame").html("<p>手机号码或卡号或姓名不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 301) {
        $(".eject_frame").html("<p>密码不能为空？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 901) {
        $(".eject_frame").html("<p>请登录后操作？</p>");
        $(".eject_operation").html("按Enter键确定");
    }
    else if (t == 501) {
        $(".eject_frame").html("<p>用户不存在？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 502) {
        $(".eject_frame").html("<p>账户或密码错误？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 503) {
        $(".eject_frame").html("<p>数量更新失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 504) {
        $(".eject_frame").html("<p>删除失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 505) {
        $(".eject_frame").html("<p>此编码无数据？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 506) {
        $(".eject_frame").html("<p>获取挂单数据失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 507) {
        $(".eject_frame").html("<p>删除挂单数据失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 508) {
        $(".eject_frame").html("<p>购物车数据获取失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 509) {
        $(".eject_frame").html("<p>添加新挂单失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 510) {
        $(".eject_frame").html("<p>支付失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 511) {
        $(".eject_frame").html("<p>充值失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 512) {
        $(".eject_frame").html("<p>账户信息获取失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 513) {
        $(".eject_frame").html("<p>验证失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 514) {
        $(".eject_frame").html("<p>交班清单失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 515) {
        $(".eject_frame").html("<p>确认失败？</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 516) {
        $(".eject_frame").html("<p>支付失败，请重新扫描条码</p>");
        $(".eject_operation").html("按ESC键返回");
    }
    else if (t == 517) {
        $(".eject_frame").html("<p>小票号码不能为空</p>");
        $(".eject_operation").html("按ESC键返回");
    }
});

var t = getQueryString("t");

/*
提示窗：窗口按键
*/
$(document).on('keydown', function (e) {
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    switch (e.keyCode) {
        case 27:            //ESC键 关闭当前窗口并操作父级页面的焦点事件
            e.preventDefault();
            if (t == 1 || t == 501 || t == 503 || t == 504 || t == 505 || t==508) {
                parent.$('#sku').focus();
            }
            else if (t == 901) {
                parent.window.location.href = "login.html";
            }
            else {
                parent.window.location.reload();
            }
            parent.layer.close(index);

            break;
        case 112:
            e.preventDefault();
            var tableId = parent.parent.document.getElementById("ice");
           
            var paperNumber = [];
            for (var i = 0; i < tableId.rows.length; i++) {
                var xgoods_id = tableId.rows[i].cells[7].innerHTML;
                paperNumber.push(xgoods_id);
            }
            DeletemerchandiseList(paperNumber);
            break;

        case 13:
            e.preventDefault();
            if (t == 901) {
                parent.parent.parent.parent.parent.window.location.href = "login.html";
            }
            break;
    }
});